<template>
<div class="content-warp">
      <div class="main-warp-one">
        <p>会员专区</p>
        <div class="main-three">
          <div class="main-once">
            <img src="@/assets/images/default_avatar.png"/>
            <div class="once-text">
              <p class="once-text-p">登录 <span class="once-text-p-linear">Lv.<span>1</span></span></p>
              <span>会员登录尊享10大特权</span>
            </div>
          </div>
          <div class="main-two">
            <img src="@/assets/discovery/teach_video_free.png"/>
            <div class="main-two-text">
              <p>以下<span style="color:#f93684">742</span><span>会员专区课程</span>
              <span>全部免费学习</span></p>
            </div>
          </div>
          <div class="main-two">
            <img src="@/assets/discovery/member_preferential.png"/>
            <div class="main-two-text">
              <p>购买非会员专区课程<span>可获会员立减优惠</span></p>
            </div>
          </div>
          <div class="main-now" v-show="OpenVip">
            <div class="now-btn"><span>立即开通</span></div>
            <p class="now-text">查看/开通 &gt;</p>
          </div>
        </div>
      </div>
      <SecondLevel></SecondLevel>
      <!-- -->
      <div class="footer-warp" v-infinite-scroll="load" :infinite-scroll-disabled="pageSize > 20" >
        <div class="footer-video" v-for="(List,index) in videoInfo" :key="index">
          <div class="video-header">
            <img :src="List.cover[0]"/>
            <div class="video-float">
                <img src="@/assets/discovery/release_play@3x.fb313c4d.png"/>
                <div>
                    <span>视频课</span>
                </div>
            </div>
            <div class="video-member"><span>会员免费</span></div>
          </div>
          <p class="video-title">{{List.title}}</p>
          <p class="video-money">
            <span>￥{{List.moreBackup.actualPrice}}</span>
            <span>{{List.statisticsBackup.viewCount / 10000 > 1?(List.statisticsBackup.viewCount / 10000).toFixed(2)+'万':List.statisticsBackup.viewCount}}人浏览</span>
          </p>
          
          <div class="icon-list">
            <div class="icon-one">
              <el-icon size="14px" class="ioc"><UserFilled /></el-icon>
              <span>{{List.statisticsBackup.praiseCount}}</span>
            </div>
            <div class="icon-one">
              <el-icon size="14px" class="ioc"><Comment /></el-icon>
              <span>{{List.statisticsBackup.commentCount}}</span>
            </div>
            <div class="icon-one">
              <el-icon size="16px" class="ioc"><StarFilled /></el-icon>
              <span>{{List.statisticsBackup.favoriteCount}}</span>
            </div>
          </div>
          <div class="video-button">
            <div class="video-button-left">
                <img class="video-button-left-head" :src="List.creatorBackup.avatar">
                <span class="video-button-left-text">{{List.creatorBackup.name}}</span>
                <img class="video-level" src="@/assets/discovery/authenticate_organ@3x.png">
            </div>
            <span class="video-button-right">{{moment(List.createTime).format('L')}}</span>
          </div>
        </div>
        <p v-if="loading">...Loading</p>
        <p v-if="loaMo" class="loaMore">加载更多</p>
      </div>
</div>
</template>
  
<script setup lang="ts">
import { computed, nextTick, onMounted, ref } from 'vue'
import useDiscoveryStore from '@/store/discovery'
import moment from 'moment'
const discoveryStore = useDiscoveryStore()
const pageSize = ref(20)
const pageNum = ref(0)
const loading = ref(false)
const loaMo = ref(false)

const OpenVip = localStorage.getItem('ACCESS_TOKEN_ZWW_2')


const videoInfo = computed(()=>{
    return discoveryStore.getcontent.slice(0,pageSize.value)
})

const load = ()=>{
    loading.value = true
    loaMo.value = false
    setInterval(() => {
        loading.value = false
        pageSize.value = 40
        if(pageSize.value == 40){
            loaMo.value = true
        }
    }, 1000)
    
}

onMounted(()=>{
    discoveryStore.getVideoList(pageSize.value,pageNum.value)
})
</script>

<style scoped lang="less">
.content-warp {
    margin: 15px auto;
    width: 1200px;
    .main-warp-one {
      background-color: white;
      height: 138px;
      border-radius: 10px;
      padding: 20px 30px 16px;
      box-sizing: border-box;
      .main-three{
        display: flex;
        justify-content: space-between;
        margin-top: 16px;

        .main-once{
            display: flex;
            height: 68px;
            align-items: center;
            &>img{
                width: 50px;
                height: 50px;
                border-radius: 50%;
                margin-right: 10px;
            }
            .once-text{
                display: flex;
                flex-direction: column;
                width: 220px;
                border-right: 1px solid #dee2e6;
                .once-text-p{
                    font-size: 16px;
                    margin-bottom: 6px;
                    .once-text-p-linear{
                        display: inline-block;
                        background-image: linear-gradient(#ff289b,#ff43d0);
                        font-style: italic;
                        font-weight: 600;
                        color: white;
                        font-size: 12px;
                        padding: 2px 6px;
                        border-radius: 4px;
                        margin-left: 6px;
                        &>span{
                            color: white;
                        }
                    }
                }
                &>span{
                    font-size: 12px;
                    color: #f93684;
                }
            }
        }
        .main-two{
            display: flex;
            width: 430px;
            justify-content: center;
            align-items: center;
            &>img{
                width: 58px;
                height: 58px;
                margin-right: 30px;
            }
            .main-two-text{
                width: 172px;
                height: 36px;
                text-align: center;
                font-size: 16px;
            }
        }
        .main-now{
            .now-btn{
                width: 80px;
                height: 32px;
                background-color: #f93684;
                border-radius: 16px;
                text-align: center;
                line-height: 32px;
                font-size: 12px;
                & > span{
                    color: white;
                }
            }
            .now-text{
                margin-top: 4px;
                width: 80px;
                color: #7d8090;
                font-size: 12px;
                text-align: center;
            }
            
        }
      }
    }
    
    .footer-warp{
        margin-top: 15px;
        width: 100%;
        display: flex;
        flex-wrap: wrap;
        .footer-video{
            width: 224px;
            background-color: white;
            border-radius: 4px;
            margin-bottom: 20px;
            &:not(:nth-child(5n)){
                margin-right: 20px;
            }
            .video-header{
                position: relative;
                & > img{
                    width: 100%;
                    height: 100%;
                    border-radius: 4px 4px 0 0;
                }
                &:hover{
                    background-color: #f93684;
                }


                .video-float{
                    position: absolute;
                    bottom: 10px;
                    left: 10px;
                    right: 10px;
                    display: flex;
                    justify-content: space-between;
                    & > img {
                        width: 30px;
                        height: 30px;
                    }
                    & > div {
                        height: 24px;
                        font-size: 12px;
                        padding: 0 12px;
                        background: rgba(0, 0, 0, 0.4);
                        border-radius: 12px;
                        & > span {
                            color: white;
                            line-height: 24px;
                        }
                    }
                }
                .video-member{
                    height: 24px;
                    padding: 0 12px;
                    font-size: 12px;
                    position: absolute;
                    top: 10px;
                    right: 10px;
                    background-color: #f93684;
                    border-radius: 12px;
                    text-align: center;
                    line-height: 24px;
                    &>span{
                        color: white;
                    }
                }
            }
            .video-title{
                padding: 4px 10px;
                display: -webkit-box;
                -webkit-box-orient: vertical;
                overflow: hidden;
                -webkit-line-clamp: 2;
                font-size: 14px;
                height: 36px;
            }
            .video-money{
                font-size: 12px;
                padding: 0 10px;
                display: flex;
                justify-content: space-between;
                align-items: center;
                span:first-child{
                    font-size: 16px;
                    color: #f93684;
                }
                span:last-child{
                    color: #b1b5c1;
                }
            }
            .icon-list{
                font-size: 12px;
                padding: 0 10px;
                display: flex;
                align-items: center;
                margin: 4px 0;
                .icon-one{
                    vertical-align: middle;
                    .ioc{
                        color: #b1b5c1 ;
                    }
                    &>span{
                        margin: 0 10px 0 4px;
                        color: #b1b5c1;
                        position: relative;
                        top: -2px;
                    }
                }
            }
            .video-button{
                display: flex;
                padding: 0 10px;
                justify-content: space-between;
                height: 50px;
                align-items: center;
                border-top: 1px solid #ebeced;
                .video-button-left{
                    display: flex;
                    align-items: center;
                    .video-button-left-head{
                        width: 24px;
                        height: 24px;
                        border-radius: 50%;
                        margin-right: 8px;
                    }
                    .video-button-left-text{
                        display: inline-block;
                        white-space: nowrap;
                        text-overflow: ellipsis;
                        width: 60px;
                        overflow: hidden;
                        
                        font-size: 12px;
                    }
                    .video-level{
                        width: 12px;
                        height: 12px;
                        margin-left: 4px;
                    }
                }
                .video-button-right{
                    font-size: 12px;
                }
            }
        }
        .loaMore{
            margin: 0 auto;
            text-align: center;
            font-size: 16px;
            border: 1px solid rgb(168, 168, 168);
            width: 140px;
            height:40px;
            line-height: 40px;
        }
    }
  }
</style>